package com.sebklebes.radar.gae.entity;

import com.beoui.geocell.model.LocationCapable;
import com.beoui.geocell.model.Point;
import com.google.appengine.api.datastore.Key;

import javax.jdo.annotations.*;
import java.util.Date;
import java.util.List;

/**
 * User:  catalin.besleaga
 * Date: 5/16/11
 * Time: 10:45 PM
 */

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class RadarEntity implements LocationCapable {

	public RadarEntity() {
	}

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;

	@Persistent
	private Double latitude;

	@Persistent
	private Double longitude;

	@Persistent
	private List<String> geocells;

	@Persistent
	private Date lastUpdate;

	@Persistent
	private Long numberOfHits;

	@NotPersistent
	private double distance;

	public Key getKey() {
		return key;
	}

	public void setKey(Key key) {
		this.key = key;
	}

	public Double getLatitude() {
		return latitude;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

	public Double getLongitude() {
		return longitude;
	}

	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}

	public Point getLocation() {
		return new Point(latitude, longitude);
	}

	public String getKeyString() {
		return Long.valueOf(key.getId()).toString();
	}

	public List<String> getGeocells() {
		return geocells;
	}

	public void setGeocells(List<String> geocells) {
		this.geocells = geocells;
	}

	public Date getLastUpdate() {
		return lastUpdate;
	}

	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}

	public Long getNumberOfHits() {
		return numberOfHits;
	}

	public void setNumberOfHits(Long numberOfHits) {
		this.numberOfHits = numberOfHits;
	}

	public double getDistance() {
		return distance;
	}

	public void setDistance(double distance) {
		this.distance = distance;
	}

	@Override
	public String toString() {
		return "RadarEntity{" +
				"key=" + key +
				", latitude=" + latitude +
				", longitude=" + longitude +
				", geocells=" + geocells +
				", lastUpdate=" + lastUpdate +
				'}';
	}
}
